<?php

namespace  App\Http\Controllers\V1;

use App\Helpers\Logger\SLogger;
use App\Helpers\RestResponseFactory;
use App\Helpers\RestUtils;
use App\Http\Controllers\Controller;
use App\Models\Factory\CoinFactory;
use App\Models\Factory\SmsFactory;
use App\Models\Factory\UserFactory;
use App\Models\Orm\Banner;
use App\Models\Orm\CoinDrawLog;
use App\Models\Orm\CoinMarket;
use App\Models\Orm\CoinStoreLog;
use App\Models\Orm\Pay;
use App\Models\Orm\Query;
use App\Models\Orm\UserCoinLog;
use App\Services\Core\Sms\Dahan\DahanService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

/**
 * Class GeetesController
 * @package App\Http\Controllers\V1
 * 短信
 */
class PayController extends  Controller
{

    /**
     * 发送短信
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function pay(Request $request)
    {
        $data['weixin'] = Pay::where('type',1)->orderBy(\DB::raw('RAND()'))->take(1)->get();
        $data['zhifubao'] = Pay::where('type',2)->orderBy(\DB::raw('RAND()'))->take(1)->get();
        $data['bank'] = Pay::where('type',3)->orderBy(\DB::raw('RAND()'))->take(1)->get()->toArray();
        //开始截取
       $address = explode(',',$data['bank'][0]['address']);
        $data['bank'][0]['bank_name'] =$address[0];
        $data['bank'][0]['bank_user_name'] =$address[1];
        $data['bank'][0]['bank_card'] =$address[2];
        $data['bank'][0]['bank_zhi_name'] =$address[3];
        $data['wallet'] = Pay::where('type',4)->orderBy(\DB::raw('RAND()'))->take(1)->get();
        return RestResponseFactory::ok($data, 200);

    }

}